package org.dllwh.milvus.v2;

import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import lombok.extern.slf4j.Slf4j;
import org.dllwh.milvus.config.MilvusConfig;

/**
 * 把今天最好的表现当作明天最新的起点．．～
 * <p>
 * Today the best performance as tomorrow the newest starter!
 *
 * @ClassName MilvusConnectHelper
 * @Description Milvus V2 连接操作
 * @Author: <a href="mailto:duleilewuhen@sina.com">独泪了无痕</a>
 * @Date 2025-05-24 14:41
 * @版本 V 1.0.1
 * @since JDK 17
 */
@Slf4j
public class MilvusConnectHelper {

    public static MilvusClientV2 getMilvusClientV2() {
        ConnectConfig config = ConnectConfig.builder()
                .uri(MilvusConfig.host + ":" + MilvusConfig.port)
                .username(MilvusConfig.userName)
                .password(MilvusConfig.password)
                .dbName(MilvusConfig.databaseName)
                // .connectTimeoutMs()
                // .idleTimeoutMs() // GRPC链接空闲的超时时间
                // .keepAliveTimeMs()
                // .keepAliveTimeoutMs()
                // .keepAliveWithoutCalls()
                .build();
        return new MilvusClientV2(config);
    }
}
